package com.fs.service.impl;

import com.fs.mapper.ServeOrdersCanceledMapper;
import com.fs.mapper.ServeOrdersMapper;
import com.fs.domain.Orders;
import com.fs.domain.OrdersCanceled;
import com.fs.domain.vo.OrderSearchDTO;
import com.ruoyi.common.utils.DateUtils;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @Description
 * @Author susu
 * @Date 2024/10/15
 */
@Service
public class ServeOrdersService implements com.fs.service.ServeOrdersService {
    @Autowired
    ServeOrdersMapper ordersMapper;

    @Autowired
    ServeOrdersCanceledMapper serveOrdersCanceledMapper;

    /**
     * 根据用户id查询订单
     * @param
     * @return
     */
    @Override
    public List<Orders> ordersAll() {
        return   ordersMapper.queryOrdersAll();
    }

    /**
     * 新增取消订单
     * @param ordersCanceled
     * @return 1or0
     */
    @Override
    public Integer addOrdersCanceled(OrdersCanceled ordersCanceled) {
        return serveOrdersCanceledMapper.addOrdersCanceled(ordersCanceled);
    }

    /**
     * 通过条件查询订单
     * @param searchDTO 通过订单编号 客户支付状态 下单时间 订单状态 支付状态 退款状态
     * @return 查询到的订单
     */
    @Override
    public List<Orders> likeQueryQrders(OrderSearchDTO searchDTO) {
        return ordersMapper.selectOrderSearchDTOList(searchDTO);
    }

    @Override
    public List<Orders> selectOrderById(Long id) {
        return ordersMapper.selectOrderById(id);
    }

    /**
     * 修改订单
     *
     * @param orders 订单
     * @return 结果
     */
    @Override
    public int updateOrders(Orders orders)
    {
        orders.setUpdateTime(DateUtils.getNowDate());
        return ordersMapper.serveUpdateOrders(orders);
    }

    /**
     *
     * @param serveItemName 服务类型
     * @return 该类型的订单数
     */
    @Override
    public int ordersByType(String serveItemName) {
        return ordersMapper.ordersByType(serveItemName);
    }


}